﻿using System;
using System.Web.Mail;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using MLY;
using MLY.Dal;
using MLY.Bll;
using System.IO;
namespace MLY.LTR
{
    public partial class AlertChangeWorkOrder : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ChangeId"] != null)
            {
                string ChangeId = Request.QueryString["ChangeId"];
                alertChangeIdHF.Value = ChangeId;

                AlertChangeCodeDS.SelectParameters.Add("ChangeId", ChangeId);
            }
            else
            {
                Response.Redirect("~/LTR/Login.aspx");
            }
        }

        protected void SubmitChanges(object sender, EventArgs e)
        {
            string PlannedDelivaryDate = (InfoFormView.FindControl("PlannedDelivaryDate") as TextBox).Text;
            string TextB = (InfoFormView.FindControl("TextFieldBBox") as TextBox).Text;
            bool error = false;

            using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MLYConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("SCCOver_AlertChangeDatabyLandingPage", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.Add("ChangeId", SqlDbType.NVarChar);
                cmd.Parameters["ChangeId"].Value = alertChangeIdHF.Value;

                cmd.Parameters.Add("PlannedDeliveryDate", SqlDbType.SmallDateTime);
                cmd.Parameters["PlannedDeliveryDate"].Value = PlannedDelivaryDate;

                cmd.Parameters.Add("TextFieldB", SqlDbType.NVarChar, 4000);
                cmd.Parameters["TextFieldB"].Value = TextB;

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Log.WriteError(ex.Message);
                    ErrorLabel.Text = ex.Message;
                    error = true;
                }
                finally
                {
                    conn.Close();
                }
            }
            if (!error)
                Response.Redirect("~/LTR/default.aspx");
        }
       
    }
}
